package com.bw.goods.mvvm.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.bw.goods.R;
import com.bw.goods.mvvm.model.entity.HomeBannerEntity;
import com.bw.mvvm_common.network.load.LoadImage;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.youth.banner.Banner;
import com.youth.banner.adapter.BannerAdapter;

import org.jetbrains.annotations.NotNull;

import java.util.List;

/**
 * @author KK
 * @description:
 * @date :2021/10/14 19:07
 */
public class HomeBnnerAdapter extends BannerAdapter<HomeBannerEntity, HomeBnnerAdapter.HomeBannerViewHolder> {

    public HomeBnnerAdapter(List<HomeBannerEntity> datas) {

        super(datas);
    }

    @Override
    public HomeBannerViewHolder onCreateHolder(ViewGroup parent, int viewType) {
        View itemview = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_home_img_banner,parent,false);
        ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
        itemview.setLayoutParams(lp);
        return new HomeBannerViewHolder(itemview);
    }

    @Override
    public void onBindView(HomeBannerViewHolder holder, HomeBannerEntity data, int position, int size) {
        LoadImage.loadMatchImg(data.imgUrl,holder.imgbanner_item);
    }

    public static class HomeBannerViewHolder extends RecyclerView.ViewHolder {

        ImageView imgbanner_item;
        public HomeBannerViewHolder(@NonNull @NotNull View itemView) {
            super(itemView);
            imgbanner_item = itemView.findViewById(R.id.imgbanner_item);

        }
    }
}
